package fpeas.pair;

import fpeas.function.Function;

public class PairUtility
{
	public static <A,B> Pair<A,B> pair(final A a,final B b)
	{
		return new Pair<A,B>()
		{
			public A first()
			{
				return a;
			}

			public B second()
			{
				return b;
			}
		};
	}

	public static <A,B> Function<Pair<A,B>,A> first()
	{
		return new Function<Pair<A,B>,A>()
		{
			public A run(final Pair<A, B> pair)
			{
				return pair.first();
			}
		};
	}

	public static <A,B> Function<Pair<A,B>,B> second()
	{
		return new Function<Pair<A,B>,B>()
		{
			public B run(final Pair<A, B> pair)
			{
				return pair.second();
			}
		};
	}
}